package leeon.kaixin.wap.util;

import leeon.mobile.BBSBrowser.utils.HTTPUtil;

import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.client.HttpClient;
import org.apache.http.conn.params.ConnManagerParams;
import org.apache.http.conn.params.ConnPerRouteBean;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.params.HttpParams;

public class HttpUtil {
	
	public static final String KAIXIN_HOST = "3g.kaixin001.com";
	
	public static final String KAIXIN_WWW_HOST = "www.kaixin001.com";
	
	public static final String KAIXIN_URL = "http://" + KAIXIN_HOST;
	
	public static final String KAIXIN_WWW_URL = "http://" + KAIXIN_WWW_HOST;
	
	public static final String KAIXIN_LOGIN_URL = KAIXIN_URL + "/home/?id=";
	
	public static final String KAIXIN_LOGOUT_URL = KAIXIN_URL + "/login/logout.php?";
	
	public static final String KAIXIN_WWW_LOGIN_URL = KAIXIN_WWW_URL + "/login/login.php";
	
	public static final String KAIXIN_WWW_LOGOUT_URL = KAIXIN_WWW_URL + "/login/logout.php";
	
	public static final String KAIXIN_STATUS_URL = KAIXIN_URL + "/home/news.php?";
	
	public static final String KAIXIN_REPASTES_URL = KAIXIN_URL + "/repaste/index.php?";
	
	public static final String KAIXIN_REPASTE_DETAIL_URL = KAIXIN_URL + "/repaste/detail.php?";
	
	public static final String KAIXIN_PIC_URL = KAIXIN_URL + "/photo/view.php?";
	
	public static final String KAIXIN_PIC_UPLOAD_URL = KAIXIN_URL + "/photo/upload_submit.php?";
	
	public static final String KAIXIN_PIC_UP_URL = KAIXIN_URL + "/photo/upload.php?";
	
	public static final String KAXIN_DAIRY_WRITE_URL = KAIXIN_URL + "/diary/write.php?";
	
	public static final String KAXIN_WWW_DAIRY_WRITE_URL = KAIXIN_WWW_URL + "/diary/write_submit.php";
	
	public static final String KAIXIN_PARAM_VERIFY = "verify=";
	
	public static final String KAIXIN_PARAM_UID = "uid=";
	
	public static final String KAIXIN_PARAM_URPID = "urpid=";
	
	public static final String KAIXIN_PARAM_PUID = "puid=";
	
	public static final String KAIXIN_PARAM_PID = "pid=";
	
	public static final String KAIXIN_PRRAM_PSTART = "start=";
	
	public static final String KAIXIN_PRRAM_PPAGE = "page=";
	
	public static final String KAIXIN_PRRAM_VIEWTYPE = "viewtype=";
	
	public static void setHeader(HttpRequest request) {
		//request.setHeader("Accept-Encoding", "gzip,deflate,sdch");
		request.setHeader("Accept-Charset", "GBK,UTF-8");
		//request.setHeader("", "");
		//request.setHeader("", "");
	}
	
	public static final HttpParams BBS_PARAMS = HTTPUtil.cloneDefault();
	static {
		ConnPerRouteBean connPerRoute = new ConnPerRouteBean(5);
		connPerRoute.setMaxForRoute(new HttpRoute(new HttpHost(KAIXIN_HOST, 80)), 5);//到kaixin 3g的路由的连接最大5个
		connPerRoute.setMaxForRoute(new HttpRoute(new HttpHost(KAIXIN_WWW_HOST, 80)), 5);//到kaixin的路由的连接最大5个
		ConnManagerParams.setMaxConnectionsPerRoute(BBS_PARAMS, connPerRoute);
	}
	public static HttpClient newInstance() {
		return HTTPUtil.newInstance(BBS_PARAMS);
	}
}
